Skip to content

gh-48 : fix add-as-submodule with deeper paths#49

Closed
bicschneider wants to merge 3 commits intomainfrom
gh-48-add-as-submodule-deeper-paths
Closed

gh-48 : fix add-as-submodule with deeper paths#49
bicschneider wants to merge 3 commits intomainfrom
gh-48-add-as-submodule-deeper-paths

Conversation

@bicschneider
Copy link
Collaborator

@bicschneider bicschneider commented Mar 3, 2026

with error message:

fatal: Invalid path '/home/claus/git-artifact/.test/10/.local/.git/modules/subm': No such file or directory

Summary by CodeRabbit

  • Bug Fixes

    • Clearer failure handling for submodule operations with explicit error messages and safer directory creation.
    • Improved runtime validation to ensure operations run inside a repository.
  • Tests

    • Stronger test execution: per-test isolation via directory handling, better aggregation of submodule issues, and appended per-test logs.
    • Improved failure messaging that points to test logs and returns proper exit codes.

@coderabbitai
Copy link

coderabbitai bot commented Mar 3, 2026

Warning

Rate limit exceeded

@bicschneider has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 0 minutes and 5 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 61d24b1 and 035cc9e.

📒 Files selected for processing (1)
  • _tests.sh
📝 Walkthrough

Walkthrough

Added runtime Git-repo validation and hardened per-test logging/working-directory handling in _tests.sh; expanded test 10 to capture submodule-add failures without aborting; in git-artifact made submodule gitdir parent creation path-aware and added explicit clone-failure handling.

Changes

Cohort / File(s) Summary
Test Script Infrastructure
_tests.sh
Added check that tests run inside a Git repo; changed per-test execution to switch directories before operations and before log generation; use git -C for artifact listing; capture and append submodule-add issues (issue1, issue2) to per-test git-test.log; improved failure messaging and exit-code handling referencing .test/<fn>/run.log.
Submodule Handling
git-artifact
Create parent directory using dirname("${modules_gitdir}") instead of a fixed .git/modules/ path to support nested module paths; add explicit error detection and message when git clone for a submodule fails and return non-zero status.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

Poem

🐰 In a repo where branches hop and play,
Tests tiptoe safely, finding their way,
Nested modules bloom where paths once failed,
Clone errors called out, no step derailed,
I nibble logs and cheer this tidy day.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'gh-48 : fix add-as-submodule with deeper paths' directly addresses the core issue fixed in the PR: supporting submodule addition with nested/deeper directory paths.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch gh-48-add-as-submodule-deeper-paths

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
_tests.sh (1)

447-453: ⚠️ Potential issue | 🟡 Minor

ok is printed even when a testcase fails.

Line 452 is outside the success path, so failures still emit ok, which is misleading for humans/parsers.

🔧 Proposed fix
-    for fn in "${test_functions[@]}"; do
-        "$fn" || {
-            echo "Test case '$fn' failed. Check the logs in .test/$fn/run.log"
-            global_exit_code=1
-        }
-        echo "ok"
-    done
+    for fn in "${test_functions[@]}"; do
+        if "$fn"; then
+            echo "ok"
+        else
+            echo "Test case '$fn' failed. Check the logs in .test/$fn/run.log"
+            global_exit_code=1
+        fi
+    done
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@_tests.sh` around lines 447 - 453, The loop prints "ok" unconditionally after
running each test, so failed tests also emit "ok"; update the loop in the test
runner that iterates over test_functions so that the success message is only
printed on success: run "$fn" and if it returns non-zero set global_exit_code=1
and print the failure message, otherwise print "ok" (i.e., move the echo "ok"
into the success branch or use an if/then/else around "$fn"). Ensure references
to test_functions, global_exit_code and the run.log path remain unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@_tests.sh`:
- Around line 457-460: The error message uses an undefined variable $fn causing
an unbound variable error; update the failure echo to reference the correct
variable $arg_testcase (i.e., change ".test/$fn/run.log" to
".test/$arg_testcase/run.log") so the message prints the real test case name and
then set global_exit_code=1 remains; locate this in the shell snippet around the
"$arg_testcase" execution branch and replace any $fn occurrences with
$arg_testcase.
- Line 441: The trap currently registered as trap 'echo "Script interrupted";
exit 130' INT TERM ERR EXIT HUP QUIT ABRT ALRM PIPE incorrectly includes EXIT
and ERR and thus forces exit 130 on every script termination; remove EXIT and
ERR from that trap so only asynchronous signals are handled (keep INT TERM HUP
QUIT ABRT ALRM PIPE) and ensure the handler remains echo "Script interrupted";
exit 130 for those signals, leaving normal exit code behavior intact for normal
exits and command errors.

---

Outside diff comments:
In `@_tests.sh`:
- Around line 447-453: The loop prints "ok" unconditionally after running each
test, so failed tests also emit "ok"; update the loop in the test runner that
iterates over test_functions so that the success message is only printed on
success: run "$fn" and if it returns non-zero set global_exit_code=1 and print
the failure message, otherwise print "ok" (i.e., move the echo "ok" into the
success branch or use an if/then/else around "$fn"). Ensure references to
test_functions, global_exit_code and the run.log path remain unchanged.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 23d78a9 and 459b815.

⛔ Files ignored due to path filters (1)
  • .test/10/git-reference.log is excluded by !**/*.log
📒 Files selected for processing (2)
  • _tests.sh
  • git-artifact

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
_tests.sh (1)

454-457: ⚠️ Potential issue | 🟠 Major

Fix undefined variable in single-testcase failure message.

Line 455 and Line 455’s path use $fn, which is undefined in this branch. With set -u, this can mask the real failure path.

🔧 Proposed fix
-        "$arg_testcase" || {
-            echo "Test case '$fn' failed. Check the logs in .test/$fn/run.log"
+        "$arg_testcase" || {
+            echo "Test case '$arg_testcase' failed. Check the logs in .test/$arg_testcase/run.log"
             global_exit_code=1
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@_tests.sh` around lines 454 - 457, The failure message uses the undefined
variable $fn which breaks under set -u; update the echo and path to reference
the actual variable $arg_testcase (e.g., echo "Test case '$arg_testcase' failed.
Check the logs in .test/$arg_testcase/run.log") and ensure the variable is
quoted everywhere (".test/$arg_testcase/run.log") so the error branch prints the
correct testcase name and path instead of referencing $fn.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@_tests.sh`:
- Around line 454-457: The failure message uses the undefined variable $fn which
breaks under set -u; update the echo and path to reference the actual variable
$arg_testcase (e.g., echo "Test case '$arg_testcase' failed. Check the logs in
.test/$arg_testcase/run.log") and ensure the variable is quoted everywhere
(".test/$arg_testcase/run.log") so the error branch prints the correct testcase
name and path instead of referencing $fn.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 459b815 and 61d24b1.

📒 Files selected for processing (1)
  • _tests.sh

@bicschneider bicschneider self-assigned this Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant